#include "copyright.h"

#include "syscall.h"
#include "Manager.h"






void manager(){
	int temporary = 0;
	int myIndex;
	int counter = 0;
	int i;
	int j;
	int temp;
	int tmp;
	
	while(1){
		/*printf("\t\t\t\t\tMANAGER\n");*/
		/* BEGIN: ON BREAK STUFF */

		/* tell the ticket clerk to go on break if need be */
		/* acquire the ticket clerk line lock to see state? */
		/*Printing("Manager trying to acquire lock %i\n", ConsoleOutput, ticketClerkLineLock, 0);*/
		AcquireLock(ticketClerkLineLockName, ticketClerkLineLockNameLength);
		/*Printing("Manager acquired lock %i\n", ConsoleOutput, ticketClerkLineLock, 0);*/
		
		/*printf("\t\t\t\t\tMAN: check if any TCs need a break.\n");*/
		for(i = 0; i < MAX_TC; i++){
			if(GetMonitor(ticketClerkStateName, ticketClerkStateNameLength, i) == 1 || GetMonitor(ticketClerkStateName, ticketClerkStateNameLength, i) == 0){ /* if available */
				/*printf("\t\t\t\t\tMAN: acquiring TC%is break lock\n", i);*/
				AcquireLock(ticketClerkBreakLockName[i], ticketClerkBreakLockNameLength[i]);
				
				if(GetMonitor(ticketClerkLineCountName, ticketClerkLineCountNameLength,i) < 3){ /* if line size is < 3 */
					/*Printing("ticketClerkLineCount[%i] < 3\n", ConsoleOutput, i, i);*/
					for(j = 0; j < MAX_TC; j++){
						if(j != i && GetMonitor(ticketClerkStateName, ticketClerkStateNameLength, j) > -1 && GetMonitor(ticketClerkBreakName, ticketClerkBreakNameLength,j) == 0 && GetMonitor(ticketClerkBreakName, ticketClerkBreakNameLength,i) == 0 && 0){ /* if there is another clerk available */
							/*Printing("inside the if statement [%i] [%i]\n", ConsoleOutput, i, j);*/
							if(Random() % 100 < 20){
								Printing("Manager has told TicketClerk %i to go on break.\n", ConsoleOutput, i, 0);
								/*printf("\t\t\t\t\tMAN: TC%i has %i in his line, take a break!\n", i, ticketClerkLineCount[i]);*/
								/*ticketClerkLineCount[i] = 0;*/
								Broadcast(ticketClerkLineConditionVariableName[i],ticketClerkLineConditionVariableNameLength[i], ticketClerkLineLockName, ticketClerkLineLockNameLength);
								if(GetMonitor(ticketClerkStateName, ticketClerkStateNameLength, i) == 0){
									Signal(ticketClerkConditionVariableName[i],ticketClerkConditionVariableNameLength[i], ticketClerkLockName[i], ticketClerkLockNameLength[i]);
								}
								SetMonitor(ticketClerkStateName, ticketClerkStateNameLength, 2, i); /* set to "break" MM: I think you should preserve the state as not busy. */
								SetMonitor(ticketClerkBreakName, ticketClerkBreakNameLength, 1, i); /* set them to on break */	
								/*currentThread->Yield();*/
								/*Yield();*/
								break;
							}
						}
					}
				} else if(GetMonitor(ticketClerkLineCountName, ticketClerkLineCountNameLength,i) > 5){
					for(j = 0; j < MAX_TC; j++){
						if(j != i && GetMonitor(ticketClerkBreakName, ticketClerkBreakNameLength, j) == 1 && 0){
							/*printf("\t\t\t\t\tMAN: TC%i get off break, TC%i is getting slammed with %i!\n", j, i, ticketClerkLineCount[i]);*/
							Printing("Manager has told TicketClerk %i to go off break.\n", ConsoleOutput, i, 0);
							Broadcast(ticketClerkLineConditionVariableName[i], ticketClerkLineConditionVariableNameLength[i], ticketClerkLineLockName, ticketClerkLineLockNameLength);
							SetMonitor(ticketClerkBreakName, ticketClerkBreakNameLength, 2, i);/* tell line to leave */
							/*ticketClerkLineCount[i] = 0;*/
							SetMonitor(ticketClerkLineCountName, ticketClerkLineCountNameLength,0,j);
							SetMonitor(ticketClerkStateName, ticketClerkStateNameLength,0,j); /* set to not busy */
							SetMonitor(ticketClerkBreakName, ticketClerkBreakNameLength, 0, j); /* set them to off break */
							Signal(ticketClerkBreakConditionVariableName[j],ticketClerkBreakConditionVariableNameLength[j], ticketClerkBreakLockName[j], ticketClerkBreakLockNameLength[j]); /* signal to come off break gets signalled even if the ticket clerk isnt waiting for on break...need to fix!*/
							/*currentThread->Yield();*/
							/*Yield();*/
							break;
						}
					}			
				}
				
				/*printf("\t\t\t\t\tMAN: releasing TC%is break lock\n", i);*/
				ReleaseLock(ticketClerkBreakLockName[i], ticketClerkBreakLockNameLength[i]);
				/*Yield();*/
			}
		}

		/* tell the concession clerk to go on break if need be */
		/* acquire the concession clerk line lock to see state? */
		/*printf("\t\t\t\t\tMAN: trying to acquire concession clerk line lock\n");*/
		AcquireLock(concessionClerkLineLockName, concessionClerkLineLockNameLength);
		
		/*printf("\t\t\t\t\tMAN: done checking TCs for breaks\n");*/
		ReleaseLock(ticketClerkLineLockName, ticketClerkLineLockNameLength);

		/*printf("\t\t\t\t\tMAN: check if any CCs need a break.\n");*/
		for(i = 0; i < MAX_CC; i++){
			if(GetMonitor(concessionClerkStateName, concessionClerkStateNameLength,i) == 1 || GetMonitor(concessionClerkStateName, concessionClerkStateNameLength,i) == 0){ /* if available */
				AcquireLock(concessionClerkBreakLockName[i], concessionClerkBreakLockNameLength[i]);
				
				if(GetMonitor(concessionClerkLineCountName, concessionClerkLineCountNameLength,i) < 3){ /* if line size is < 3 */
					for(j = 0; j < MAX_TC; j++){
						if(j != i && GetMonitor(concessionClerkStateName, concessionClerkStateNameLength,j) > -1 && GetMonitor(concessionClerkBreakName,concessionClerkBreakNameLength,j) == 0 && GetMonitor(concessionClerkBreakName, concessionClerkBreakNameLength, i) == 0 && 0){ /* if there is another clerk available */
							if(Random() % 100 < 20){
								/*printf("\t\t\t\t\tMAN: CC%i has %i in his line, take a break!\n", i, concessionClerkLineCount[i]);*/
								Printing("Manager has told ConcessionClerk %i to go on break.\n", ConsoleOutput, i, 0);
								/*concessionClerkLineCount[i] = 0;*/
								Broadcast(concessionClerkLineConditionVariableName[i],concessionClerkLineConditionVariableNameLength[i], concessionClerkLineLockName, concessionClerkLineLockNameLength);
								if(GetMonitor(concessionClerkStateName, concessionClerkStateNameLength, i) == 0){
									Signal(concessionClerkConditionVariableName[i], concessionClerkConditionVariableNameLength[i], concessionClerkLockName[i], concessionClerkLockNameLength[i]);
								}
								SetMonitor(concessionClerkStateName, concessionClerkStateNameLength,2,i); /* set to "break" */
								SetMonitor(concessionClerkBreakName, concessionClerkBreakNameLength,1,i); /* set them to on break */
								/*currentThread->Yield();*/
								/*Yield();*/
								break;
							}
						}
					}
				} else if(GetMonitor(concessionClerkLineCountName, concessionClerkLineCountNameLength,i) > 5){
					for(j = 0; j < MAX_TC; j++){
						if(j != i && GetMonitor(concessionClerkBreakName, concessionClerkBreakName,j) == 1 && 0){
							/*printf("\t\t\t\t\tMAN: CC%i get off break, CC%i is getting slammed with %i!\n", j, i, concessionClerkLineCount[i]);*/
							Broadcast(concessionClerkLineConditionVariableName[i],concessionClerkLineConditionVariableNameLength[i], concessionClerkLineLockName, concessionClerkLineLockNameLength);
							SetMonitor(concessionClerkBreakName, concessionClerkBreakNameLength, 2,i); /* tell line to leave */
							/*concessionClerkLineCount[i] = 0;*/
							SetMonitor(concessionClerkLineCountName, concessionClerkLineCountNameLength, 0,j);
							SetMonitor(concessionClerkStateName, concessionClerkStateNameLength, 0, j); /* set to not busy */
							SetMonitor(concessionClerkBreakName, concessionClerkBreakNameLength,0, j); /* set them to off break */ 
							Signal(concessionClerkBreakConditionVariableName[j], concessionClerkBreakConditionVariableNameLength[j], concessionClerkBreakLockName[j], concessionClerkBreakLockNameLength[j]); /* signal to come off break */
							/*currentThread->Yield();*/
							/*Yield();*/
							break;
						}
					}			
				}
				
				ReleaseLock(concessionClerkBreakLockName[i], concessionClerkBreakLockNameLength[i]);
				/*Yield();*/
			}
		}

		/* tell the ticket taker to go on break if need be */
		/* acquire the ticket taker line lock to see state? */
		/*printf("\t\t\t\t\tMAN: trying to acquire ticket taker line lock to check for breaks\n");*/
		AcquireLock(ticketTakerLineLockName, ticketTakerLineLockNameLength);

		/*printf("\t\t\t\t\tMAN: done checking CCs for breaks\n");*/
		ReleaseLock(concessionClerkLineLockName, concessionClerkLineLockNameLength);

		/*printf("\t\t\t\t\tMAN: acquired ticket taker line lock to check for breaks\n");*/

		/*printf("\t\t\t\t\tMAN: check if any TTs need a break.\n");*/
		for(i = 0; i < MAX_TT; i++){
			if(GetMonitor(ticketTakerStateName, ticketTakerStateNameLength,i) == 1 || GetMonitor(ticketTakerStateName, ticketTakerStateNameLength,i) == 0){ /* if available */
				/*printf("\t\t\t\t\tMAN: trying to acquire TT%is break lock\n", i);*/
				AcquireLock(ticketTakerBreakLockName[i], ticketTakerBreakLockNameLength[i]);
				/*printf("\t\t\t\t\tMAN: acquired TT%is break lock\n", i);*/
				
				if(GetMonitor(ticketTakerLineCountName, ticketTakerLineCountNameLength, i) < 3){ /* if line size is < 3 */
					for(j = 0; j < MAX_TT; j++){
						if(j != i && GetMonitor(ticketTakerStateName, ticketTakerStateNameLength, j) > -1 && GetMonitor(ticketTakerBreakName, ticketTakerBreakNameLength,j) == 0 && GetMonitor(ticketTakerBreakName, ticketTakerBreakNameLength,i) == 0 && 0){ /* if there is another taker available */
							if(Random() % 100 < 20){
								/*printf("\t\t\t\t\tMAN: TT%i has %i in his line, take a break!\n", i, ticketTakerLineCount[i]);*/
								
								Printing("Manager has told TicketTaker %i to go on break.\n", ConsoleOutput, i, 0);
								/*ticketTakerLineCount[i] = 0;*/
								Broadcast(ticketTakerLineConditionVariableName[i],ticketTakerLineConditionVariableNameLength[i], ticketTakerLineLockName, ticketTakerLineLockNameLength);
								if(GetMonitor(ticketTakerStateName,ticketTakerStateNameLength,i) == 0){
									Signal(ticketTakerConditionVariableName[i], ticketTakerConditionVariableNameLength[i], ticketTakerLockName[i], ticketTakerLockNameLength[i]);
								}
								SetMonitor(ticketTakerStateName, ticketTakerStateNameLength, 2, i); /* set to "break" */
								SetMonitor(ticketTakerBreakName,ticketTakerBreakNameLength, 1, i); /* set them to on break */
								/*currentThread->Yield();*/
								/*Yield();*/
								break;
							}
						}
					}
				} else if(GetMonitor(ticketTakerLineCountName,ticketTakerLineCountNameLength, i) > 5){
					for(j = 0; j < MAX_TT; j++){
						if(j != i && GetMonitor(ticketTakerBreakName, ticketTakerBreakNameLength,j) == 1 && 0){
							/*printf("\t\t\t\t\tMAN: TT%i get off break, TT%i is getting slammed with %i!\n", j, i, ticketTakerLineCount[i]);*/
							Broadcast(ticketTakerLineConditionVariableName[i],ticketTakerLineConditionVariableNameLength[i], ticketTakerLineLockName,  ticketTakerLineLockNameLength);
							SetMonitor(ticketTakerBreakName, ticketTakerBreakNameLength,2,i); /* tell line to leave */
							/*ticketTakerLineCount[i] = 0;*/
							SetMonitor(ticketTakerLineCountName, ticketTakerLineCountNameLength, 0, j);
							SetMonitor(ticketTakerStateName, ticketTakerStateNameLength,0,j); /* set to not busy */
							SetMonitor(ticketTakerBreakName,ticketTakerBreakNameLength,0, j); /* set them to off break */
							Signal(ticketTakerBreakConditionVariableName[j],ticketTakerBreakConditionVariableNameLength[j], ticketTakerBreakLockName[j],ticketTakerBreakLockNameLength[j]); /* signal to come off break */
							/*currentThread->Yield();*/
							/*Yield();*/
							break;
						}
					}			
				}
				
				ReleaseLock(ticketTakerBreakLockName[i],ticketTakerBreakLockNameLength[i]);
				/*Yield();*/
			}
		}

		/*printf("\t\t\t\t\tMAN: about to release ticket taker line lock after checking for breaks\n*/
		/*ReleaseLock(ticketTakerLineLock);*/
		/*printf("\t\t\t\t\tMAN: released ticket taker line lock after checking for breaks\n");*/
		
		/* END: ON BREAK STUFF */
	
		/*printf("\t\t\t\t\tMAN: trying to acquire movie data lock\n");*/
		AcquireLock(movieDataLockName, movieDataLockNameLength);
		/*printf("\t\t\t\t\tMAN: acquired movie data lock\n");*/
		/* lock all the ticket takers */
		/*printf("\t\t\t\t\tMAN: trying to acquire ticket taker line lock to acquire ticket taker locks\n");*/
		/*AcquireLock(ticketTakerLineLock);*/ /* checking ticketTakerStates */
		/*printf("\t\t\t\t\tMAN: acquired ticket taker line lock to acquire ticket taker locks\n");*/
		for(i = 0; i < MAX_TT; i++){
			if(GetMonitor(ticketTakerStateName, ticketTakerStateNameLength,i) > -1){
				/*printf("\t\t\t\t\tMAN: trying to acquire TT%i taker lock\n", i);*/
				AcquireLock(ticketTakerLockName[i], ticketTakerLockNameLength[i]);
				/*printf("\t\t\t\t\tMAN: acquired TT%i taker lock\n", i);*/
			}
		}
		/*printf("\t\t\t\t\tMAN: about to release ticket taker line lock after acquiring ticket taker locks\n");*/
		/*ReleaseLock(ticketTakerLineLock);*/
		/*printf("\t\t\t\t\tMAN: released ticket taker line lock after acquiring ticket taker locks\n");*/
		
		/*printf("\t\t\t\t\tMAN: can we start the movie? startNumber:%i, numberAdmitted:%i; seatsFilled:%i; movieStartTime:%i; counter:%i\n", NUM_ROWS*ROW_SIZE - 3, numberAdmitted, seatsFilled, movieStartTime, counter);*/
		Printing("Manager is checking to start a movie. numberAdmitted = %i; seatsFilled = %i\n", ConsoleOutput, GetMonitor(numberAdmittedName, numberAdmittedNameLength,0), GetMonitor(seatsFilledName, seatsFilledNameLength, 0));
		Printing("movieStartTime = %i; counter = %i\n", ConsoleOutput, GetMonitor(movieStartTimeName, movieStartTimeNameLength, 0), counter);
		if(GetMonitor(numberAdmittedName, numberAdmittedNameLength,0) == GetMonitor(seatsFilledName, seatsFilledNameLength, 0) && GetMonitor(movieStartTimeName, movieStartTimeNameLength,0) == 0 && GetMonitor(seatsFilledName, seatsFilledNameLength, 0) != 0 && GetMonitor(numberAdmittedName, numberAdmittedNameLength,0) > NUM_ROWS*ROW_SIZE - 3 || (counter > 10 && GetMonitor(numberAdmittedName, numberAdmittedNameLength,0) > 0 && GetMonitor(numberAdmittedName, numberAdmittedNameLength,0) == GetMonitor(seatsFilledName, seatsFilledNameLength, 0))){ /*if people have been waiting in the theater for a while, start the movie*/
			/*printf("\t\t\t\t\tMAN: yo lets get this partay started!\n");*/
			Printing("Manager is telling the MovieTechnnician to start the movie.\n", ConsoleOutput, 0, 0);
			Signal(technicianDataConditionVariableName,technicianDataConditionVariableNameLength, movieDataLockName, movieDataLockNameLength);
			SetMonitor(movieEndedName, movieEndedNameLength, 0, 0);
			SetMonitor(movieStartTimeName, movieStartTimeNameLength, 1, 0);
			
			/* check the ticket clerk registers */
			/*printf("\t\t\t\t\tMAN: checking the ticket clerk registers\n");*/
			for(i = 0; i < MAX_TC; i++){
				/*printf("\t\t\t\t\tMAN: acquiring line lock before reading registers\n");*/
				/*Printing("Manager checking lock %i for registers\n", ConsoleOutput, ticketClerkLineLock, 0);*/
				AcquireLock(ticketClerkLineLockName, ticketClerkLineLockNameLength);
				if(GetMonitor(ticketClerkStateName, ticketClerkStateNameLength, i) > -1){
					AcquireLock(ticketClerkLockName[i], ticketClerkLockNameLength[i]);
					tmp = GetMonitor(ticketClerkRegisterName, ticketClerkRegisterNameLength, i);
					SetMonitor(ticketMoneyName, ticketMoneyNameLength, GetMonitor(ticketMoneyName, ticketMoneyNameLength,0) + tmp, 0);
					Printing("Manager collected %i from TicketClerk%i.\n", ConsoleOutput, GetMonitor(ticketClerkRegisterName, ticketClerkRegisterNameLength, i), i);
					SetMonitor(ticketClerkRegisterName, ticketClerkRegisterNameLength,0,i);
					ReleaseLock(ticketClerkLockName[i], ticketClerkLockNameLength[i]);
				}
				/*printf("\t\t\t\t\tMAN: releasing line lock after reading registers\n");*/
				ReleaseLock(ticketClerkLineLockName, ticketClerkLineLockNameLength);
			}
			/*printf("\t\t\t\t\tMAN: we have made $%i so far from tickets\n", ticketMoney);*/
			
			/* check the concession clerk registers */
			/*printf("\t\t\t\t\tMAN: checking the concession clerk registers\n");*/
			for(i = 0; i < MAX_CC; i++){
				AcquireLock(concessionClerkLineLockName, concessionClerkLineLockNameLength);
				if(GetMonitor(concessionClerkStateName, concessionClerkStateNameLength,i) > -1){
					AcquireLock(concessionClerkLockName[i], concessionClerkLockNameLength[i]);
					tmp = GetMonitor(concessionClerkRegisterName, concessionClerkRegisterNameLength, i);
					SetMonitor(concessionMoneyName, concessionMoneyNameLength, GetMonitor(concessionMoneyName, concessionMoneyNameLength, i) + tmp, 0);
					Printing("Manager collected %i from ConcessionClerk%i.\n", ConsoleOutput, GetMonitor(concessionClerkRegisterName, concessionClerkRegisterNameLength, i), i);
					SetMonitor(concessionClerkRegisterName, concessionClerkRegisterNameLength, 0, i);
					ReleaseLock(concessionClerkLockName[i], concessionClerkLockNameLength[i]);
				}
				ReleaseLock(concessionClerkLineLockName, concessionClerkLineLockNameLength);
			}
			
			Printing("Total money made by office = %i \n", ConsoleOutput, (GetMonitor(ticketMoneyName, ticketMoneyNameLength, 0) + GetMonitor(concessionMoneyName, concessionMoneyNameLength, 0)), 0);
			
			/*printf("\t\t\t\t\tMAN: we have made $%i so far from concessions\n", concessionMoney);	*/		
		}
		
		/*printf("\t\t\t\t\tMAN: i forget, did a movie just finish?\n");*/
		if(GetMonitor(movieEndedName, movieEndedNameLength, 0) == 1){
		/*	printf("\t\t\t\t\tMAN: movies over! people can line up again\n");*/
			counter = 0;
			SetMonitor(movieStartTimeName, movieStartTimeNameLength, 0, 0);
			SetMonitor(movieEndedName, movieEndedNameLength,0, 0);
			/*printf("\t\t\t\t\tMAN: about to acquire ticket taker line lock for broadcast\n");*/
			/*AcquireLock(ticketTakerLineLock);*/
			/*printf("\t\t\t\t\tMAN: acquired ticket taker line lock for broadcast\n");*/
			/*printf("\t\t\t\t\tMAN: broadcast\n");*/
			Broadcast(lobbyConditionVariableName, lobbyConditionVariableNameLength, ticketTakerLineLockName, ticketTakerLineLockNameLength);
			/*printf("\t\t\t\t\tMAN: about to release ticket taker line lock for broadcast\n");*/
			/*ReleaseLock(ticketTakerLineLock);*/
			/*printf("\t\t\t\t\tMAN: released ticket taker line lock for broadcast\n");*/
		}
		
		/* release all the ticket clerks */
		/*printf("\t\t\t\t\tMAN: trying to acquire ticket taker line lock to release ticket taker locks\n");*/
		/*AcquireLock(ticketTakerLineLock);*/ /* checking ticketTakerStates */
		/*printf("\t\t\t\t\tMAN: acquired ticket taker line lock to release ticket taker locks\n");*/
		for(i = 0; i < MAX_TT; i++){
			if(GetMonitor(ticketTakerStateName, ticketTakerStateNameLength,i) > -1){
				/*printf("\t\t\t\t\tMAN: releasing TT%is taker lock\n", i);*/
				ReleaseLock(ticketTakerLockName[i], ticketTakerLockNameLength[i]);
				/*printf("\t\t\t\t\tMAN: released TT%is taker lock\n", i);*/
			}
		}
		
		AcquireLock(counterLockName, counterLockNameLength);
		
		/*printf("\t\t\t\t\tMAN: about to release ticket taker line lock to release ticket taker locks\n");*/
		ReleaseLock(ticketTakerLineLockName, ticketTakerLineLockNameLength);
		/*printf("\t\t\t\t\tMAN: released ticket taker line lock to release ticket taker locks\n");*/
		
		/*printf("\t\t\t\t\tMAN: Waiting yo\n");*/
		/*Wait(technicianDataConditionVariable, movieDataLock);*/
		/*printf("\t\t\t\t\tMAN: about to release movie data lock\n");*/
		ReleaseLock(movieDataLockName, movieDataLockNameLength);
		/*printf("\t\t\t\t\tMAN: released movie data lock\n");*/
		
		
		/*printf("\t\t\t\t\tMAN: custCounter = %i\n", custCounter);*/
		Printing("custCounter = %i\n", ConsoleOutput, GetMonitor(custCounterName, custCounterNameLength, 0), 0);
		temp = GetMonitor(custCounterName, custCounterNameLength, 0);
		ReleaseLock(counterLockName, counterLockNameLength);
		
		if(temp == 0){
			Printing("Total money made by office = %i \n", ConsoleOutput, (GetMonitor(ticketMoneyName, ticketMoneyNameLength,0) + GetMonitor(concessionMoneyName, concessionMoneyNameLength, 0)), 0);
			/*printf("\t\t\t\t\tMAN: closing shop, no customers left\n")*/
			/*printf("\t\t\t\t\tMAN: we have made $%i from tickets\n", ticketMoney);*/
			/*printf("\t\t\t\t\tMAN: we have made $%i from concessions\n", concessionMoney);*/
			break;
		}
		
		counter++;
		/*currentThread->Yield();*/
		Yield();
	}
	
	SetMonitor(ManagerFinishedName, ManagerFinishedNameLength, 1, 0);
	
	/*ticketClerk*/
	for(temporary = 0; temporary < 3; temporary++){
		AcquireLock(ticketClerkLockName[temporary], ticketClerkLockNameLength[temporary]);
		Broadcast(ticketClerkConditionVariableName[temporary], ticketClerkConditionVariableNameLength[temporary], ticketClerkLockName[temporary], ticketClerkLockNameLength[temporary]);
		ReleaseLock(ticketClerkLockName[temporary], ticketClerkLockNameLength[temporary]);
		
		AcquireLock(ticketClerkBreakLockName[temporary], ticketClerkBreakLockNameLength[temporary]);
		Broadcast(ticketClerkBreakConditionVariableName[temporary], ticketClerkBreakConditionVariableNameLength[temporary], ticketClerkBreakLockName[temporary], ticketClerkBreakLockNameLength[temporary]);
		ReleaseLock(ticketClerkBreakLockName[temporary], ticketClerkBreakLockNameLength[temporary]);
	}
	/*concession clerk*/
	for(temporary = 0; temporary < 3; temporary++){
		AcquireLock(concessionClerkLockName[temporary], concessionClerkLockNameLength[temporary]);
		Broadcast(concessionClerkConditionVariableName[temporary], concessionClerkConditionVariableNameLength[temporary], concessionClerkLockName[temporary], concessionClerkLockNameLength[temporary]);
		ReleaseLock(concessionClerkLockName[temporary], concessionClerkLockNameLength[temporary]);
		
		AcquireLock(concessionClerkBreakLockName[temporary], concessionClerkBreakLockNameLength[temporary]);
		Broadcast(concessionClerkBreakConditionVariableName[temporary],concessionClerkBreakConditionVariableNameLength[temporary],  concessionClerkBreakLockName[temporary], concessionClerkBreakLockNameLength[temporary]);
		ReleaseLock(concessionClerkBreakLockName[temporary], concessionClerkBreakLockNameLength[temporary]);
	}
	/*ticket taker*/
	for(temporary = 0; temporary < 3; temporary++){
		AcquireLock(ticketTakerLockName[temporary], ticketTakerLockNameLength[temporary]);
		Broadcast(ticketTakerConditionVariableName[temporary], ticketTakerConditionVariableNameLength[temporary], ticketTakerLockName[temporary], ticketTakerLockNameLength[temporary]);
		ReleaseLock(ticketTakerLockName[temporary], ticketTakerLockNameLength[temporary]);

		AcquireLock(ticketTakerBreakLockName[temporary], ticketTakerBreakLockNameLength[temporary]);
		Broadcast(ticketTakerBreakConditionVariableName[temporary], ticketTakerBreakConditionVariableNameLength[temporary], ticketTakerBreakLockName[temporary], ticketTakerBreakLockNameLength[temporary]);
		ReleaseLock(ticketTakerBreakLockName[temporary], ticketTakerBreakLockNameLength[temporary]);
	}
	
	/*Technician*/
	AcquireLock(movieDataLockName, movieDataLockNameLength);
	Broadcast(technicianDataConditionVariableName,technicianDataConditionVariableNameLength, movieDataLockName, movieDataLockNameLength);
	ReleaseLock(movieDataLockName, movieDataLockNameLength);
}


int main(){
	Printing("Manager!\n", ConsoleOutput, 0, 0);
	
	manager();

	Exit(1);
}